/**
 * 
 */
package systole.ioHandling.logs;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.*;

/**
 * @author juan
 *
 */
public class SystoleLogger {

    private static SystoleLogger systoleLogger = null;
    private Log rootLogger;

    private SystoleLogger() {
        this.rootLogger = LogFactory.getLog("systole");
    }

    private void initLog() {
        Properties logProperties = new Properties();
        try {
            // load our log4j properties / configuration file
            logProperties.load(new FileInputStream(""));
            PropertyConfigurator.configure(logProperties);
            this.rootLogger.info("Logging initialized.");
        } catch (IOException e) {
           // ignoro
        }
    }

    /**
     * @return Return the unique instance of log. Singleton.
     */
    public static SystoleLogger getInstance() {
        if (systoleLogger == null) {
            systoleLogger = new SystoleLogger();
            systoleLogger.initLog();
        }
        return systoleLogger;
    }

    /**
     * @param message Error message to log.
     */
    public void logError(String message) {
        this.rootLogger.error(message);
    }

    /**
     * @param message Debug message to log.
     */
    public void logDebug(String message) {
        this.rootLogger.debug(message);
    }

    /**
     * @param message Info message to log.
     */
    public void logInfo(String message) {
        this.rootLogger.info(message);
    }
}
